package com.activity;

import android.os.Bundle;
import android.view.View;

import com.activity.fragment.AttendanceSetFragment;
import com.activity.fragment.ClockFragment;
import com.activity.shop.ClockRecordActivity;
import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.activity.home.PageActivity;
import com.example.apple.ddhr_new.utils.ActivityUtil;

import java.util.ArrayList;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class AttendanceActivity extends PageActivity {

    private String[] mTitleDataList;
    private ArrayList<Fragment> fragments =new ArrayList();
    @Override
    public String[] titles() {
        if(mTitleDataList==null){
            if(App.getInstance().getAccount().getUserstoreinfo()!=null&&App.getInstance().getAccount().getUserstoreinfo().size()>0){

                if(App.getInstance().getAccount().getUserstoreinfo().get(0).getUserstorecategory().equals("1")||App.getInstance().getAccount().getUserstoreinfo().get(0).getUserstorecategory().equals("2")){
                    mTitleDataList = new String[]{getString(R.string.daka),getString(R.string.kaoqin_shezhi)};
                }else {
                    mTitleDataList = new String[]{getString(R.string.daka)};
                }


            }else {
                mTitleDataList = new String[]{getString(R.string.daka),getString(R.string.kaoqin_shezhi)};
            }

        }

        return mTitleDataList;
    }

    @Override
    public ArrayList<Fragment> fragments() {

        if(fragments.size()==0){


            if(App.getInstance().getAccount().getUserstoreinfo()!=null&&App.getInstance().getAccount().getUserstoreinfo().size()>0){

                if(App.getInstance().getAccount().getUserstoreinfo().get(0).getUserstorecategory().equals("1")||App.getInstance().getAccount().getUserstoreinfo().get(0).getUserstorecategory().equals("2")){
                    fragments.add(new ClockFragment());
                    fragments.add(new AttendanceSetFragment());
                }else {
                    fragments.add(new ClockFragment());

                }


            }else {
                fragments.add(new ClockFragment());
            }


        }

        return  fragments;
    }
    @Override
    protected int titleText() {
        return R.string.kaoqin_guanli;
    }
    @Override
    protected void created(@Nullable Bundle savedInstanceState) {
        super.created(savedInstanceState);
        setTitleRight(getString(R.string.daka_jilu));
        if(App.getInstance().getAccount().getUserstoreinfo().get(0).getUserstorecategory().equals("1")||App.getInstance().getAccount().getUserstoreinfo().get(0).getUserstorecategory().equals("2")){
            magicIndicator.setVisibility(View.VISIBLE);
        }else {
            magicIndicator.setVisibility(View.GONE);
        }
    }

    @Override
    protected void titleRightClick() {
        ActivityUtil.startActivity(this,ClockRecordActivity.class);
    }
}
